home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / lib / firefox-3.5.5 / firefox.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  2009-11-09  |  4KB  |  149 lines

  1. #!/bin/sh
  2.  
  3. # Firefox launcher containing a Profile migration helper for
  4. # temporary profiles used during alpha and beta phases.
  5.  
  6. # Authors:
  7. #  Alexander Sack <asac@jwsdot.com>
  8. #  Fabien Tassin <fta@sofaraway.org>
  9. #  Steve Langasek <steve.langasek@canonical.com>
  10. # License: GPLv2 or later
  11.  
  12. ## profile migration disabled for now, instead, resurrect the previous code
  13.  
  14. # If there's still no ~/mozilla/firefox-3.5 profile, try to find a previous
  15. # firefox profile and initialize with that.
  16. # If nothing is found, we'll go for a fresh run and let firefox create a
  17. # default profile for us.
  18.  
  19. MOZDIR=$HOME/.mozilla
  20. LIBDIR=/usr/lib/firefox-3.5.5
  21. APPVER=3.5
  22. META_NAME=firefox
  23. GDB=/usr/bin/gdb
  24. DROPPED=abandoned
  25.  
  26. NAME=`which "$0"`
  27. if [ "x$META_NAME" != "x" ] ; then
  28.   NAME="${NAME%%-$APPVER}"
  29. fi
  30. APPNAME="$(basename "$NAME")"
  31.  
  32. while [ ! -f "$LIBDIR/$APPNAME" ] && [ -L "$NAME" ]; do
  33.   TARGET="$(readlink "$NAME")"
  34.   if [ "x$TARGET" = "x$(basename "$TARGET")" ]; then
  35.     TARGET="$(dirname "$NAME")/$TARGET"
  36.   fi
  37.   if [ "x$META_NAME" != "x" ] ; then
  38.     TARGET=${TARGET%%-$APPVER}
  39.   fi
  40.   NAME="$TARGET"
  41.   APPNAME="$(basename "$NAME")"
  42.   if [ "x$APPNAME" = "xfirefox.sh" ]; then
  43.     APPNAME=firefox
  44.     break
  45.   fi
  46. done
  47.  
  48. usage () {
  49.   $LIBDIR/$APPNAME -h | sed -e 's,/.*/,,'
  50.   echo
  51.   echo "        -g or --debug        Start within $GDB (Must be first)"
  52. }
  53.  
  54. want_debug=0
  55. while [ $# -gt 0 ]; do
  56.   case "$1" in
  57.     -h | --help | -help )
  58.       usage
  59.       exit 0 ;;
  60.     -g | --debug )
  61.       want_debug=1
  62.       shift ;;
  63.     -- ) # Stop option prcessing
  64.       shift
  65.       break ;;
  66.     * )
  67.       break ;;
  68.   esac
  69. done
  70.  
  71. # if there exists a beta profile (first found: $MOZDIR/firefox-3.5,
  72. # $MOZDIR/firefox-3.1) and there is a standard firefox profile as well, ask the
  73. # user what to do. In case he decides to import the firefox 3.0 profile
  74. # settings, we keep the firefox directory untouched, but rename the beta
  75. # profile by appending the suffix |.abandoned|. In case the user decides to
  76. # keep using the firefox 3.5 profile, we rename the original firefox profile to
  77. # firefox.3.0-replaced and rename the beta profile to be |.mozilla/firefox|.
  78. #
  79. # as a third option the user can defer his final decision. This will leave the
  80. # directories untouched, thus making the user use the old firefox profile by
  81. # default.
  82. #
  83. # in addition, even older profiles are renamed too, by appending |.abandoned|
  84. # to their name.
  85.  
  86. FOUND=""
  87. if [ -d $MOZDIR/firefox ] ; then
  88.   FOUND=firefox
  89. fi
  90.  
  91. FOUND_BETA=""
  92. BETA_LIST=""
  93. for betaname in firefox-3.1 firefox-3.5; do
  94.   if [ -d $MOZDIR/$betaname ]; then
  95.     BETA_LIST="$BETA_LIST $betaname"
  96.     FOUND_BETA=$betaname
  97.   fi
  98. done
  99.  
  100. if [ "$FOUND" != "" -a "$FOUND_BETA" != "" ] ; then
  101.   echo -n "Found Beta Participation ..."
  102.   $LIBDIR/ffox-35-beta-profile-migration-dialog
  103.   result=$?
  104.   if [ $result = 1 ]; then
  105.      mv $MOZDIR/$FOUND $MOZDIR/$FOUND.3.0-replaced
  106.      mv $MOZDIR/$FOUND_BETA $MOZDIR/$FOUND
  107.      for beta in $BETA_LIST ; do
  108.        if [ $beta != $FOUND_BETA ] ; then
  109.          mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  110.        fi
  111.      done
  112.      echo " keep beta profile."
  113.   elif [ $result = 2 ]; then
  114.      for beta in $BETA_LIST ; do
  115.        mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  116.      done
  117.      echo " use firefox 3.0 profile."
  118.   else
  119.      echo " use firefox 3.0 profile, but will ask again next time."
  120.   fi
  121.   echo " ... will check again next time."
  122. elif [ "$FOUND_BETA" != "" -a "$FOUND" = "" ]; then
  123.   # in case we only have a beta profile the user most likely wants to use
  124.   # that. just doing, no questions asked.
  125.   mv $MOZDIR/$FOUND_BETA $MOZDIR/firefox
  126.   for beta in $BETA_LIST ; do
  127.     # Move out the older beta profiles
  128.     if [ $beta != $FOUND_BETA ] ; then
  129.       mv $MOZDIR/$beta $MOZDIR/$beta.$DROPPED
  130.     fi
  131.   done
  132.   echo "*NOTICE* Profile $FOUND_BETA found and moved as main profile"
  133. fi
  134.  
  135. if [ $want_debug -eq 1 ] ; then
  136.   if [ ! -x $GDB ] ; then
  137.     echo "Sorry, can't find usable $GDB. Please install it."
  138.     exit 1
  139.   fi
  140.   tmpfile=`mktemp /tmp/mozargs.XXXXXX` || { echo "Cannot create temporary file" >&2; exit 1; }
  141.   trap " [ -f \"$tmpfile\" ] && /bin/rm -f -- \"$tmpfile\"" 0 1 2 3 13 15
  142.   echo "set args ${1+"$@"}" > $tmpfile
  143.   echo "$GDB $LIBDIR/$APPNAME -x $tmpfile"
  144.   $GDB "$LIBDIR/$APPNAME" -x $tmpfile
  145.   exit $?
  146. else
  147.   exec $LIBDIR/$APPNAME "$@"
  148. fi
  149.